import { http } from "@/utils/http";
import { baseURLApi, type resResult, type pageData } from "./utils";

type ArticlePage = {
  id: number;
  articleTitle: string;
  categoryName: string;
  summary: string;
  tagNameList: string[];
  cover: string;
  isTop: number;
  status: number;
  createTime: Date;
  updateTime: Date;
};
type ArticleDetial = {
  id: number;
  articleTitle: string;
  categoryName: string;
  summary: string;
  tagNameList: string[];
  cover: string;
  content: string;
  isTop: number;
  status: number;
  createTime: Date;
  updateTime: Date;
};
export const getArticleList = (data?: string) => {
  return http.request<pageData<ArticlePage>>(
    "get",
    baseURLApi("/article/getArticleList"),
    { params: data }
  );
};

export const getArticleById = (id?: number) => {
  return http.request<resResult<ArticleDetial>>(
    "get",
    baseURLApi(`/article/getArticleById/${id}`)
  );
};
